#include <stdio.h>
int Partition(int* nums, int low, int high)
{
    int pivot = nums[low];
    while (low < high)
    {
        while (low < high && nums[high] >= pivot)
            --high;
        nums[low] = nums[high];
        while (low < high && nums[low] <= pivot)
            ++low;
        nums[high] = nums[low];
    }
    nums[low] = pivot;
    return low;
}
void Qsort(int* nums, int low, int high)
{
    if (low < high)
    {
        int pivot = Partition(nums, low, high);
        Qsort(nums, low, pivot-1);
        Qsort(nums, pivot+1, high);
    }
}
int main(void)
{
    int nums[8] = {49, 38, 65, 97, 76, 13, 27, 49};
    Qsort(nums, 0, 7);
    // Partition(nums, 0, 7);
    for (int i = 0; i < 8; ++i)
        printf("%3d", nums[i]);

    return 0;
}